//
//  USERINFOManage.m
//  archive_ Write_File
//
//  Created by shaorui on 15/9/2.
//  Copyright (c) 2015年 archive_ Write_File. All rights reserved.
//

#import "USERINFOManage.h"
#import "ReferenceMacro.h"
static USERINFOManage * _shareManage  = nil;
@implementation USERINFOManage

+(USERINFOManage *)shareUserManage
{
     static dispatch_once_t predicate;
    dispatch_once(&predicate, ^{
        _shareManage = [[USERINFOManage alloc] init];
      
    });
    return _shareManage;
    
}
-(BOOL)isLogin
{
    
    
    return isLoginYes;
}

    /**
     *
     *    //得到并返回文件路径
     **/
-(NSString *)documentsFilePath:(NSString *) fileName {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSLog(@"%@",[documentsDirectory stringByAppendingPathComponent:fileName]);
    
    return [documentsDirectory stringByAppendingPathComponent:fileName];
    
}

    ///读档
-(USERINFOOne *)readUserInfo
{
    
    
    USERINFOOne * userInfo = [NSKeyedUnarchiver unarchiveObjectWithFile:[self documentsFilePath:Key_user_fiel_Name]];
    
    
    return userInfo;
}

    ///是否已登陆
+ (BOOL)isLogin
{
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    
    return [userDefaults boolForKey:@"islog"];
}
    ///归档

-(BOOL)saveInsetUserInfo:(USERINFOOne *)USER
{
    BOOL isSuccess = NO;
    
   isSuccess = [NSKeyedArchiver archiveRootObject:USER toFile:[self documentsFilePath:Key_user_fiel_Name]];
    isLoginYes = isSuccess;

    return isSuccess;
}

-(BOOL)updateUserInfo:(USERINFOOne *)UpdateUSER
{
    BOOL isSuccess = NO;
    
    isSuccess = [NSKeyedArchiver archiveRootObject:UpdateUSER toFile:[self documentsFilePath:Key_user_fiel_Name]];

    return isSuccess;
    
}

-(BOOL)deleteUserInfo
{
    
    BOOL isSuccess = NO;
    
    
    
    
    
    
    
    
    
    
    return isSuccess;
}
@end
